{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# jump sample config\n",
    "import utils.BagExtractor as BagExtractor\n",
    "\n",
    "input_bag = \"/home/dji/dataset/OmniCamCalibration/OmniCAM_2/camera_2_calibration_3_13.bag\"\n",
    "step = 2\n",
    "topics = [\"/oak_ffc_4p/assemble_image/compressed\"]\n",
    "ouput_bag_path = \"/home/dji/dataset/OmniCamCalibration/OmniCAM_2/jump_sample_2\"\n",
    "\n",
    "BagExtractor.jump_sample_bag(input_bag, step, topics, ouput_bag_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# extract bag for failed calibration\n",
    "import utils.BagExtractor as BagExtractor\n",
    "extract_topics  = \"CAM_D,CAM_A\" # or \"CAM_D,CAM_A\" or \"CAM_A,CAM_B\" or \"CAM_B,CAM_C\"\n",
    "input_bag = \"/home/dji/dataset/OmniNxt/Calibration/omni_calibration_2024-06-25-00-00-25_bag/omni_calibration_CAMD-CAMA_fix.bag\"\n",
    "oringnal_topics = \"/oak_ffc_4p/assemble_image/compressed\"\n",
    "step = 1 \n",
    "\n",
    "BagExtractor.extract_individual_calibration_bag(input_bag, oringnal_topics, extract_topics , step)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# calibrate failed mono case, input file should be named as CAM_X.bag, we get topic from the bag name\n",
    "import utils.Calibration as Calibration\n",
    "input_bag = \"/home/dji/dataset/CAM_A.bag\"\n",
    "\n",
    "Calibration.calibrate_mono(input_bag)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# calibrate failed stereo case input file should be named as CAM_X-CAM_X.bag, we get topic from the bag name\n",
    "import utils.Calibration as Calibration\n",
    "input_bag = \"/home/dji/dataset/OmniNxt/Calibration/omni_calibration_2024-06-25-00-00-25_bag/CAM_D-CAM_A.bag\"\n",
    "\n",
    "Calibration.calibrate_stereo(input_bag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# calibrate failed mono-imu case input file should be named as CAM_X.bag, we get topic from the bag name, imu yaml should under the same folder\n",
    "import utils.Calibration as Calibration\n",
    "input_bag = None\n",
    "\n",
    "Calibration.calibrate_imu(input_bag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# regenerate fisheye yaml\n",
    "import utils.VirtualStereoCalibration as VirtualStereoCalibration\n",
    "input_bag = None\n",
    "fov = 190\n",
    "width = 320\n",
    "height = 240\n",
    "ouput_path = None\n",
    "fisheye_cofigs = None\n",
    "VirtualStereoCalibration.generate_fisheye_yaml(input_bag, fov, width, height, ouput_path, fisheye_cofigs)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
